using System.Windows.Controls;
using FileTransferDesktop.ViewModels.Controls;
using Wpf.Ui.Abstractions.Controls;
using AuthDialogViewModel = FileTransferDesktop.ViewModels.Dialogs.AuthDialogViewModel;

namespace FileTransferDesktop.Views.Dialogs;

/// <summary>
/// AuthDialogControl.xaml 的交互逻辑
/// </summary>
public partial class AuthDialogControl : UserControl
{
    private readonly AuthDialogViewModel _viewModel;

    public AuthDialogControl(AuthDialogViewModel viewModel)
    {
        InitializeComponent();
        _viewModel = viewModel;
        DataContext = _viewModel;
        if (viewModel is INavigationAware navigation)
        {
            navigation.OnNavigatedToAsync();
        }
    }

    /// <summary>
    /// 设置对话框模式
    /// </summary>
    /// <param name="isRegisterMode">true为注册模式，false为登录模式</param>
    public void SetMode(bool isRegisterMode)
    {
        _viewModel.SetMode(isRegisterMode);
    }

    /// <summary>
    /// 清理资源
    /// </summary>
    public static void Cleanup()
    {
        // 这里可以清理任何资源或取消订阅事件
        // 目前没有需要特别清理的内容
    }
}
